<template>
  <div>
    <el-dialog :visible.sync="uploadCad" title="添加CAD记录" center width="30%">
      <div style="display: flex;flex-direction: column;align-items: center">
        <el-radio-group v-model="type">
          <el-radio :label="1">初尺</el-radio>
          <el-radio :label="2">第一次复尺</el-radio>
          <el-radio :label="3">第二次复尺</el-radio>
          <el-radio :label="4">第三次复尺</el-radio>
        </el-radio-group>
        <div style="margin-top: 15px">
          <span>
            CAD图纸：
          </span>
          <upload-excel
              v-if="uploadCad"
              style="margin-top: 10px"
              :type="'图纸'"
              @addStatus="handleUploadSuccess"
          />
        </div>

      </div>
      <span slot="footer">
         <el-button size="small" style="color: #666;background-color:#eee;" @click="uploadCad=false">取 消</el-button>
        <el-button size="small" type="primary" @click="_submit">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import uploadExcel from "./uploadExcel.vue";

export default {
  name: "compoundRuler",
  components: {
    uploadExcel
  },
  data() {
    return {
      uploadCad: false,
      type: 1,
      assignTaskId: "",
      cadUrl: "",
    }
  },
  methods: {
    handleOpen(row) {
      this.uploadCad = true
      this.assignTaskId = row.assignTaskId
    },
    handleUploadSuccess(val) {
      if (val.type == '图纸') {
        this.cadUrl = val.file
      }
    },
    _submit() {
      if (!this.cadUrl) return this.$message.warning('CAD图纸必传！')
      const data = {
        assignTaskId: this.assignTaskId,
        cadUrl: this.cadUrl,
        type: this.type
      }
      this.$api.assignAddCadLog(data).then(res => {
        if (res == 1) {
          this.$emit('addStatus', 1)
          this.$message.success('提交成功！')
          this.uploadCad = false
        }
      })
    }
  }
}
</script>

<style scoped lang="less">
span {
  font-weight: bold;
}

/deep/ .el-upload-dragger {
  width: 430px;
}
</style>